package com.sunshine.lnuplus.service

import android.app.Service
import android.content.Intent
import android.os.Binder
import android.os.IBinder
import com.sunshine.lnuplus.callback.LoadDataCallBack
import com.sunshine.lnuplus.internet.LoadFunction

class LoadFunctionService : Service() {

    private var functionList = ArrayList<ArrayList<String>>()

    override fun onBind(intent: Intent): IBinder {
        return MyBind()
    }

    inner class MyBind : Binder(){
        fun getService(): LoadFunctionService {
            return this@LoadFunctionService
        }
    }

    /**
     * 请注意，不能再onCreate中调用LoadFunction，
     * 因为那时还没有setCallBack会导致异常
     */
    fun setCallBack(callBack: LoadDataCallBack){
        LoadFunction(this, functionList, callBack)
    }

    fun getFunctionList(): ArrayList<ArrayList<String>> {
        return functionList
    }

}
